/*
 * jxSwing Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxSwing.component.button;

import java.awt.Dimension;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

import javax.swing.ImageIcon;

import org.jxSwing.i18n.I18N;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxSwing
 * @package org.jxSwing.component.button
 * @date 20/04/2014 - 20:37:25
 */
public class RefreshButton extends ActionButton {
	
	private static final long serialVersionUID = 275138010462128264L;
	
	private static ImageIcon ICON_32x32 = null;
	
	/**
	 * 
	 */
	public RefreshButton() {
	
		super("refresh", "16x16", new Dimension(25, 25));
		
		setToolTipText(I18N.component().refresh());
		
		ICON_32x32 = getImageIcon("refresh", "32x32");
		
		addComponentListener(new ComponentAdapter() {
			
			@Override
			public void componentResized(final ComponentEvent componentEvent) {
			
				//
				if(getSize().getHeight() < 32 || getSize().getWidth() < 32) {
					
					setIcon(getDefaultIcon());
					
				}else {
					
					setIcon(ICON_32x32);
				}
			}
		});
	}
}
